#ifndef __CTHREADS_H__
#define __CTHREADS_H__

#include "ThreadStarter.h"

//the state of the thread
enum CThreadState
{
	THREADSTATE_TERMINATED = 0,//terminate
	THREADSTATE_PAUSED    = 1,//paused
	THREADSTATE_SLEEPING  = 2,//in sleep
	THREADSTATE_BUSY      = 3,//busy
	THREADSTATE_AWAITING  = 4,//awaiting
};

//base class for thread
class CThread : public ThreadBase
{

public:
	CThread();
	~CThread();
	virtual bool Run();
	virtual void OnShutdown();

	//set the state of the thread
	__forceinline void SetThreadState(CThreadState thread_state)
	{ 
		ThreadState = thread_state;
	}

	//get the state of the thread
	__forceinline CThreadState GetThreadState()
	{ 
		return ThreadState;
	}

	//get thread ID
	int GetThreadId()
	{ 
		return ThreadId;
	}

	//get the started time
	time_t GetStartTime() 
	{
		return start_time;
	}

protected:
	CThreadState ThreadState;//thread state
	time_t start_time;
	int ThreadId;//thread ID
};

#endif//__CTHREADS_H__

